var local="http://47.104.10.151";

var page=0;
var page1=0;
var totalPages=0;
var totalPages1=0;
function createXMLHttp() {
    //使用大部分浏览器
    var xmlHttp;
    if(window.XMLHttpRequest){
        xmlHttp=new XMLHttpRequest();
    }
    if(window.ActiveXObject){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        if(!xmlHttp){
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
    }
    return xmlHttp;
}


function onClickAjax_resume(){
    var xmlHttp = createXMLHttp();
    var txt = "";//用于存储拼接字符串；
    //拼接字符
    txt ="page=" + page;
    var url=local+":8080/resume/findResumeAllByPage";
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            var result = xmlHttp.responseText;
            var json = eval("(" + result + ")");

            totalPages=json.data.totalPages;

            var input1 = document.getElementsByName("talent1");
            input1[0].value = json.data.content[0].name;
            input1[1].value = json.data.content[0].age;
            input1[2].value = json.data.content[0].skills;
            input1[3].value = json.data.content[0].service_area;
            input1[4].value = json.data.content[0].mobile;
            input1[5].value = json.data.content[0].area;

            totalPages=json.data.totalPages;

            var input2 = document.getElementsByName("talent2");
            input2[0].value = json.data.content[1].name;
            input2[1].value = json.data.content[1].age;
            input2[2].value = json.data.content[1].skills;
            input2[3].value = json.data.content[1].service_area;
            input2[4].value = json.data.content[1].mobile;
            input2[5].value = json.data.content[1].area;


            var input3 = document.getElementsByName("talent3");
            input3[0].value = json.data.content[2].name;
            input3[1].value = json.data.content[2].age;
            input3[2].value = json.data.content[2].skills;
            input3[3].value = json.data.content[2].service_area;
            input3[4].value = json.data.content[2].mobile;
            input3[5].value = json.data.content[2].area;


            var input4 = document.getElementsByName("talent4");
            input4[0].value = json.data.content[3].name;
            input4[1].value = json.data.content[3].age;
            input4[2].value = json.data.content[3].skills;
            input4[3].value = json.data.content[3].service_area;
            input4[4].value = json.data.content[3].mobile;
            input4[5].value = json.data.content[3].area;


            var input5 = document.getElementsByName("talent5");
            input5[0].value = json.data.content[4].name;
            input5[1].value = json.data.content[4].age;
            input5[2].value = json.data.content[4].skills;
            input5[3].value = json.data.content[4].service_area;
            input5[4].value = json.data.content[4].mobile;
            input5[5].value = json.data.content[4].area;


            var input6 = document.getElementsByName("talent6");
            input6[0].value = json.data.content[5].name;
            input6[1].value = json.data.content[5].age;
            input6[2].value = json.data.content[5].skills;
            input6[3].value = json.data.content[5].service_area;
            input6[4].value = json.data.content[5].mobile;
            input6[5].value = json.data.content[5].area;
        }
    }
}

function nextPage_bid_decision() {

    if(totalPages>page+1){
        for(var i=0;i<document.getElementsByName("talent1").length;i++){
            document.getElementsByName("talent1")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent2").length;i++){
            document.getElementsByName("talent2")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent3").length;i++){
            document.getElementsByName("talent3")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent4").length;i++){
            document.getElementsByName("talent4")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent5").length;i++){
            document.getElementsByName("talent5")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent6").length;i++){
            document.getElementsByName("talent6")[i].value="";
        }
        page++;
        onClickAjax_resume();
    }
    else alert("已经是最后一页");
}


function beforePage_bid_decision() {

    if(page-1>=0){
        for(var i=0;i<document.getElementsByName("talent1").length;i++){
            document.getElementsByName("talent1")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent2").length;i++){
            document.getElementsByName("talent2")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent3").length;i++){
            document.getElementsByName("talent3")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent4").length;i++){
            document.getElementsByName("talent4")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent5").length;i++){
            document.getElementsByName("talent5")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talent6").length;i++){
            document.getElementsByName("talent6")[i].value="";
        }
        page--;
        onClickAjax_resume();
    }
    else alert("第一页");
}


function onClickAjax_Reresume() {
    xmlHttp = createXMLHttp();
    var txt = "";//用于存储拼接字符串；
    //拼接字符
    txt = "page=" + page1;
    var url = local+":8080/ReqResume/findResumeBypage";
    xmlHttp.open("POST", url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.send(txt);
    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            var result = xmlHttp.responseText;
            var json = eval("(" + result + ")");

            totalPages1 = json.data.totalPages;

            var input1 = document.getElementsByName("talen1");
            input1[0].value = json.data.content[0].name;
            input1[1].value = json.data.content[0].mobile;
            input1[2].value = json.data.content[0].skills;
            input1[3].value = json.data.content[0].service_area;
            input1[4].value = json.data.content[0].money_area;

            totalPages1=json.data.totalPages;

            var input2 = document.getElementsByName("talen2");
            input2[0].value = json.data.content[1].name;
            input2[1].value = json.data.content[1].mobile;
            input2[2].value = json.data.content[1].skills;
            input2[3].value = json.data.content[1].service_area;
            input2[4].value = json.data.content[1].money_area;


            var input3 = document.getElementsByName("talen3");
            input3[0].value = json.data.content[2].name;
            input3[1].value = json.data.content[2].mobile;
            input3[2].value = json.data.content[2].skills;
            input3[3].value = json.data.content[2].service_area;
            input3[4].value = json.data.content[2].money_area;


            var input4 = document.getElementsByName("talen4");
            input4[0].value = json.data.content[3].name;
            input4[1].value = json.data.content[3].mobile;
            input4[2].value = json.data.content[3].skills;
            input4[3].value = json.data.content[3].service_area;
            input4[4].value = json.data.content[3].money_area;


            var input5 = document.getElementsByName("talen5");
            input5[0].value = json.data.content[4].name;
            input5[1].value = json.data.content[4].mobile;
            input5[2].value = json.data.content[4].skills;
            input5[3].value = json.data.content[4].service_area;
            input5[4].value = json.data.content[4].money_area;


            var input6 = document.getElementsByName("talen6");
            input6[0].value = json.data.content[5].name;
            input6[1].value = json.data.content[5].mobile;
            input6[2].value = json.data.content[5].skills;
            input6[3].value = json.data.content[5].service_area;
            input6[4].value = json.data.content[5].money_area;
        }
    }
}



function nextPage_bid_decision1() {

    if(totalPages1>page1+1){
        for(var i=0;i<document.getElementsByName("talen1").length;i++){
            document.getElementsByName("talen1")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen2").length;i++){
            document.getElementsByName("talen2")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen3").length;i++){
            document.getElementsByName("talen3")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen4").length;i++){
            document.getElementsByName("talen4")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen5").length;i++){
            document.getElementsByName("talen5")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen6").length;i++){
            document.getElementsByName("talen6")[i].value="";
        }
        page1++;
        onClickAjax_Reresume();
    }
    else alert("已经是最后一页");
}


function beforePage_bid_decision1() {
    if(page1-1>=0){
        for(var i=0;i<document.getElementsByName("talen1").length;i++){
            document.getElementsByName("talen1")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen2").length;i++){
            document.getElementsByName("talen2")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen3").length;i++){
            document.getElementsByName("talen3")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen4").length;i++){
            document.getElementsByName("talen4")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen5").length;i++){
            document.getElementsByName("talen5")[i].value="";
        }
        for(var i=0;i<document.getElementsByName("talen6").length;i++){
            document.getElementsByName("talen6")[i].value="";
        }
        page1--;
        onClickAjax_Reresume();
    }
    else alert("第一页");
}

function home() {
    onClickAjax_resume();
    onClickAjax_Reresume();
}